package sebjul.ecom.dao;

import java.util.*;

import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
import javax.persistence.*;


import sebjul.ecom.entities.*;

@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class OrderDao {
	
	@PersistenceContext
	EntityManager em;
	
	public Order createOrder(Order order) {
		em.persist(order);
		return order;
	}
	
	public Order findOrderById (int id) {
		return em.find(Order.class, id);
	}
	
	public void deleteOrder(Order order) {
		em.remove(em.merge(order));
	}
	
	public Order updateOrder(Order order) {
		return em.merge(order);
	}
	
}